<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .move{
            width: 100px;
            height: 100px;
            background-color: blueviolet;
            position: absolute;
        }
        .movea{
            width: 100px;
            height: 100px;
            background-color: blueviolet;
            position: absolute;
            top: 110px;
        }
    </style>
</head>
<body>
    <div class="move"></div>
    <div class="movea"></div>

    <script>
        var move=document.querySelector(".move")
        var movea=document.querySelector(".movea")
        
        var int=setInterval(function(){
            var left=move.offsetLeft;
            var speed=(1000-left)/10  //越减得出的值越小
            speed=speed>0?Math.ceil(speed):Math.floor(speed)
            // console.log(speed);
                left+=speed    //加在这里的值越来越小

            console.log(left);
            if(left==1000)
            {
                clearInterval(int)
            }
            move.style.left=left+'px'  //所以每次位移幅度越来越小
           
        },1000)
    </script>
    
</body>
</html>